<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Hello React!</title>
<script src="https://cdn.staticfile.org/react/16.4.0/umd/react.development.js"></script>
<script src="https://cdn.staticfile.org/react-dom/16.4.0/umd/react-dom.development.js"></script>
<script src="https://cdn.staticfile.org/babel-standalone/6.26.0/babel.min.js"></script>
</head>
<body>
<h1>State 状态保存数据</h1>
<p>在自定义组件构造方法中初始化要放到state中的数据，在组件内部使用 this.state 获取状态</p>
<div id="example"></div>
<script type="text/babel">
	class Clock extends React.Component{
		constructor(props) {
		    super(props);
			{/* {} 可能还有保存键值对的功能 */}
			this.state = {date:new Date()};
		}
		
		render(){
			return <h2>当前时间为: {this.state.date.toLocaleString()}</h2> ;
		}
	}
	
	ReactDOM.render(
		<Clock/>,
		document.getElementById('example')
	);
</script>

</body>
</html>